package com.khalil.kkadmin.module.quicklink;

import com.khalil.kkadmin.common.web.RespResult;
import com.khalil.kkadmin.infrastructure.BaseController;
import com.khalil.kkadmin.infrastructure.web.security.WebContext;
import com.khalil.kkadmin.module.quicklink.domain.QuickLink;
import com.khalil.kkadmin.module.quicklink.service.QuickLinkService;
import com.khalil.kkadmin.module.quicklink.vo.QuickLinkGroupVo;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("quickLink")
@RestController
public class QuickLinkController extends BaseController<QuickLinkService, QuickLink, Long> {
    public QuickLinkController(QuickLinkService service) {
        super(service);
    }

    @GetMapping("listGroupsWithLinks")
    public RespResult<List<QuickLinkGroupVo>> listGroupsWithTools() {
        String username = WebContext.getUsername();
        List<QuickLinkGroupVo> quickLinkGroupVos = service.listGroupsWithLinks(username);
        return RespResult.ok(quickLinkGroupVos);
    }

    @DeleteMapping("deleteGroupWithLinks")
    public void deleteGroupWithLinks(Long groupId) {
        service.deleteGroupWithLinks(groupId);
    }
}
